<template>
	<view class="x-main-content">
		<u-navbar bgColor="#fff" :fixed="true" leftIconColor="#333" leftIconSize="42rpx" autoBack placeholder
			title="请选择医院">
		</u-navbar>
		<view style="position: fixed;width: 100%;z-index: 9;height: 50rpx;right: 0;">
			<serach @toSearch='toSearch' @updateList='updateList'></serach>
		</view>
		<view class="classifyWrap">
			<radio-group>
				<view class="administrator" @click="radioCheck(index)" v-for="(item,index) in showHospList" :key="index">
					<view class="aaa">
						<image :src="item.logo" mode=""></image>
						<view class="information">
							<text class="yiyuan">{{item.name}}</text>
							<view class="little">
								<text>{{item.level}}</text>
								<text class="marginright">丨</text>
								<text class="marginright">{{item.nature}}</text>
							</view>
						</view>
					</view>
					<view class="content_item_left">
						<radio size="13px" color="#2979ff" shape="circle" :value="item.id"
							:checked="item.id == radioValue"></radio>
					</view>
				</view>
			</radio-group>
		</view>
	</view>
</template>

<script>
	import serach from '@/components/search.vue'
	export default {
		components: {
			serach
		},
		data() {
			return {
				radioValue: '',
				loadStatus: 'loadmore',
				hospitalList: [],
				showHospList: []
			}
		},
		created() {
			this.getHospitalData()
		},
		methods: {
			leftClick() {
				uni.navigateBack({
					delta: 1
				});
			},
			radioCheck(index) {
				let data = this.hospitalList[index]
				this.$store.commit('SET_HOSPITAL', data);
				// uni.setStorageSync("hospital",data)
				uni.$emit('hospital', data)
				// console.log(data)
				this.$nextTick(() => {
					uni.navigateBack({
						delta: 1
					});
				})
			},
			async getHospitalData() {
				let data = {
					cityCode: uni.getStorageSync('myAddress').cityId

				}
				let res = await this.$request('/api/index/getAllHospitalList', data, 'GET')
				console.log(res)
				this.hospitalList = res.data.rows
				this.showHospList = res.data.rows
			},
			toSearch(ctx) {
				this.showHospList = this.hospitalList.filter(i => {
					return i.name.includes(ctx)
				})
			},
			updateList() {
				this.showHospList = this.hospitalList
			}
		}
	}
</script>

<style lang="scss" scoped>
	.x-main-content {
		padding: 0 30rpx;
	}

	.classifyWrap {
		margin-top: 120rpx;
		padding-bottom: 30rpx;
	}

	.administrator {
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #ffffff;
		height: 80px;
		margin-top: 10px;
		border-radius: 9px;
		padding: 19rpx;

		image {
			width: 142rpx;
			height: 142rpx;
		}

		.aaa {
			display: flex;
		}

		.information {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding: 16rpx 0;
			margin-left: 28rpx;
			min-width: 0;

			.yiyuan {
				font-size: 32rpx;
				font-family: PingFangSC-Semibold, PingFang SC;
				font-weight: 600;
				color: #333333;
				letter-spacing: 2px;
				width: 400rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.little {
				font-size: 26rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				color: #6F7DA2;
				height: 40rpx;
				line-height: 40rpx;
			}
		}
	}

	/deep/.uni-radio-input {
		width: 13px;
		height: 13px;
	}
</style>